package gameUi
{
	import flash.events.Event;

	public class Card extends CardSymbol
	{
		private var _cardType:int;//花色
		private var _cardNum:int;//数字
		
		/**
		 * 牌类 
		 * @param cardType 花色 黑桃0 红条1 方片2 梅花3
		 * @param cardNum 数字 1~13 由2到A
		 */
		public function Card(cardType:int,cardNum:int)
		{
			_cardType = cardType;
			_cardNum = cardNum;
			addEventListener(Event.ENTER_FRAME,checkFram);
		}
		
		private function checkFram(e:Event):void{
			if(this.currentFrame == 10 || this.currentFrame == 11 || this.currentFrame == 12){//显示牌花色
				var tempNum:int = _cardType*13 + _cardNum;
				if(card) card.gotoAndStop(tempNum);
			}
			if(this.currentFrame == 12){
				removeEventListener(Event.ENTER_FRAME,checkFram);
			}
		}
		
		/**
		 * 显示牌背面
		 **/
		public function closeBg():void
		{
			addEventListener(Event.ENTER_FRAME,closeFram);
		}
		
		private function closeFram(e:Event):void{
			if(card){
				card.gotoAndStop(53);
			}
		}
		
		/**
		 * 销毁
		 **/
		public function destory():void{
			removeEventListener(Event.ENTER_FRAME,checkFram);
			removeEventListener(Event.ENTER_FRAME,closeFram);
			if(this.parent) this.parent.removeChild(this);
		}

		/**
		 * 牌类型（牌点）
		 **/
		public function get cardNum():int
		{
			return _cardNum;
		}

	}
}